package com.dxl.common.model.easyui;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

@JsonInclude(Include.NON_NULL)
public class TreeNode {
	public static final boolean CHECKED = true;
	public static final boolean UNCHECKED = false;
	public static final String OPEN = "open";
	public static final String CLOSED = "closed";
	private String id; // node id, which is important to load remote data
	private String text; // node text to show
	private String state; // node state, 'open' or 'closed', default is 'open'. When set to 'closed', the node have children nodes and will load them from remote site
	private boolean checked; // Indicate whether the node is checked selected.
	private Map<String, String> attributes; // custom attributes can be added to a node
	private List<TreeNode> children; // an array nodes defines some children nodes
	
	public TreeNode() {}
	
	public TreeNode(String id, String text) {
		this(id, text, null, false);
	}
	
	public TreeNode(String id, String text, String state) {
		this(id, text, state, false);
	}
	
	public TreeNode(String id, String text, String state, boolean checked) {
		this.id = id;
		this.text = text;
		this.state = state;
		this.checked = checked;
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public boolean isChecked() {
		return checked;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}
	public Map<String, String> getAttributes() {
		return attributes;
	}
	public void setAttributes(Map<String, String> attributes) {
		this.attributes = attributes;
	}
	public List<TreeNode> getChildren() {
		return children;
	}
	public void setChildren(List<TreeNode> children) {
		this.children = children;
	}
	@Override
	public String toString() {
		return JSONObject.toJSONString(this);
	}
}
